//
//  CY_DetailTableViewCell.m
//  悦享
//
//  Created by dllo on 16/3/19.
//  Copyright © 2016年 张洪国. All rights reserved.
//

#import "CY_DetailTableViewCell.h"

@interface CY_DetailTableViewCell ()

/// 歌曲名label
@property (nonatomic, retain) UILabel *nameLabel;
/// 歌手label
@property (nonatomic, retain) UILabel *singerLabel;
/// 心形图片
@property (nonatomic, retain) UIImageView *img;
/// 点赞数量
@property (nonatomic, retain) UILabel *numberLabel;

@end

@implementation CY_DetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    
    return self;
    
}

- (void)setModel:(SongsModel *)model {
    
    _model = model;
    
    _nameLabel.text = _model.name;
    _singerLabel.text = _model.singerName;
    NSString *str = [NSString stringWithFormat:@"%@" , _model.favorites];
    _numberLabel.text = str;
    _img.image = [UIImage imageNamed:@"iconfont-xin"];
    
}

- (void)createViews {
    
    self.numLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_numLabel];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_nameLabel];
    
    self.singerLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_singerLabel];
    
    self.img = [[UIImageView alloc] init];
    [self.contentView addSubview:_img];
    
    self.numberLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_numberLabel];
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    _numLabel.frame = CGRectMake(0, 0, 50, self.contentView.frame.size.height);
    _numLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.backgroundColor = [UIColor clearColor];
    _numLabel.textColor = [UIColor grayColor];
    
    CGSize size = [APPTools labelRectWithSize:CGSizeMake(self.contentView.frame.size.width, self.contentView.frame.size.height * 0.6) LabelText:_model.name Font:[UIFont systemFontOfSize:17]];
    CGSize singerSize = [APPTools labelRectWithSize:CGSizeMake(self.contentView.frame.size.width, self.contentView.frame.size.height * 0.4) LabelText:_model.singerName Font:[UIFont systemFontOfSize:15]];
    
    self.nameLabel.frame = CGRectMake(self.numLabel.frame.size.width, 0, size.width, self.contentView.frame.size.height * 0.6);
    self.singerLabel.frame = CGRectMake(self.numLabel.frame.size.width, self.nameLabel.frame.size.height, singerSize.width, self.contentView.frame.size.height * 0.4);
    _singerLabel.backgroundColor = [UIColor clearColor];
    _singerLabel.font = [UIFont systemFontOfSize:15];
    _singerLabel.textColor = [UIColor grayColor];
    
    self.img.frame = CGRectMake(self.singerLabel.frame.origin.x + singerSize.width, self.nameLabel.frame.size.height, self.contentView.frame.size.height * 0.4, self.contentView.frame.size.height * 0.4);
    _img.backgroundColor = [UIColor clearColor];
    
    self.numberLabel.frame = CGRectMake(self.img.frame.origin.x + self.contentView.frame.size.height * 0.4, self.nameLabel.frame.size.height, 70, self.contentView.frame.size.height * 0.4);
    _numberLabel.textColor = [UIColor grayColor];
    _numberLabel.font = [UIFont systemFontOfSize:15];
    _numberLabel.backgroundColor = [UIColor clearColor];
    
    
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
